import { CreateCategoryDto } from "../../types/model/product/dtos/category.dto";
import Request from "@/common/utils/request/index";

enum Api {
  CreateCategory = "/jeecgboot/posCategories/createCategory",
  EditCategory = "/jeecgboot/posCategories/edit",
  RemoveCategory = "/jeecgboot/posCategories/delete",
  GetCategories = "/jeecgboot/posCategories/list",
  UpdateStatus = "/jeecgboot/posCategories/updateStatus",
}

export const createCategory = (params: CreateCategoryDto) => {
  return Request.getInstance().send<void>({
    url: Api.CreateCategory,
    method: "POST",
    data: params,
  });
};

export const getCategories = (params: any) => {
  return Request.getInstance().send<any>({
    url: Api.GetCategories,
    method: "GET",
    params,
  });
};

export const editCategory = (params: CreateCategoryDto) => {
  return Request.getInstance().send<string>({
    url: Api.EditCategory,
    method: "POST",
    data: params,
  });
};

export const removeCategory = (id: string) => {
  return Request.getInstance().send<string>({
    url: Api.RemoveCategory + `?id=${id}`,
    method: "POST",
  });
};

export const updateStatus = (params: { id: string; status: "1" | "2" }) => {
  return Request.getInstance().send<string>({
    url: Api.UpdateStatus,
    method: "POST",
    data: params,
  });
};
